package com.qfedu.entity;

import lombok.Data;

/**
 * 作者：刘随阳
 * 时间: 2021/7/31 9:12
 * 描述：神光照耀,太白成瑞。六丙来迎,百福悠归
 *     code值为400失败，值为200成功
 */
@Data
public class ResultVo<T>{
    private Integer code;
    private String msg;
    private T data;

    private ResultVo(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T>ResultVo success(String msg,T data){
        return new ResultVo(ResultStatus.SUCCESS,msg,data);
    }

    public static ResultVo success(String msg){
        ResultVo resultVo = success(msg,null);
        return resultVo;
    }

    public static ResultVo success(){
        ResultVo resultVo = success(null);
        return resultVo;
    }

    public static <T>ResultVo fail(String msg,T data){
        return new ResultVo(ResultStatus.FAIL,msg,data);
    }

    public static ResultVo fail(String msg){
        ResultVo resultVo = fail(msg,null);
        return resultVo;
    }

    public static ResultVo fail(){
        ResultVo resultVo = fail(null);
        return resultVo;
    }

    public static ResultVo loginStatus(int loginCode,String msg){
       return new ResultVo(loginCode,msg,null);
    }
}
